//
//  EditScene.h
//  HelloCpp
//
//  Created by apple  on 13-6-16.
//
//

#ifndef __XIAOLIAN__EditScene__
#define __XIAOLIAN__EditScene__


#include "cocos2d.h"
#include "Box2D/Box2D.h"
#include "LevelScene.h"
#include "BCSManager.h"
#include "AccountManager.h"

#include "cocos-ext.h"

USING_NS_CC_EXT;
USING_NS_CC;

struct PosRot 
{
	PosRot(){}
	PosRot(const CCPoint& pos, float rot, int item);

	CCPoint m_pos;
	float	m_rot;
	int		m_item;
};

//EditScene

class EditScene : public LevelScene, public CCTextFieldDelegate, public BCSDelegate, public AccountManagerDelegate
{
public:
	EditScene();
    virtual ~EditScene();
    
    static CCScene* create();
    
    virtual void onEnter();
    virtual void onExit();
    
    bool init();
    
	void reset();
	void debug();
	std::string saveLevel(const char* levelName);
	std::string saveImage(const char* imageName);

	virtual void successed();
	virtual void failed();
    virtual void update(float dt);
    
    void menuItemClick(CCObject* sender);
	void actionSlider(CCObject* pSender, unsigned int);

	void myScoreChanged(int score);
	void updateMyScore();


	virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent);
	virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent);
	virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent);

	void willDownloadFile(const char* filename);
	void willUploadFile(const char* filename);

	void didDownloadFile(const char* filename);
	void didUploadFile(const char* filename);

protected:
	int							m_createNodeTag;
	CCNode*						m_pMovingNode;
	bool						m_bDebug;
	std::vector<PosRot>			m_orgBodyPos;
	unsigned int				m_score;

	CCControlSlider*			m_pSlider;
};

#endif /* defined(__XIAOLIAN__EditScene__) */
